package com.testing.match;

import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.util.regex.Pattern.*;

/**
 * @author Administrator
 */
public class StartMatch {

    public static void main(String[] args) throws Exception {
        String filePath = "C:\\Users\\Administrator\\Desktop\\tapd2020-09.txt";
        File file = new File(filePath);
        if (!file.exists()) {
            System.out.println("文件不存在");
            return;
        }
        // 创建re表达式
        Pattern pattern = compile("bug_id=\"[0-9]\\d+\"");
        FileInputStream fileInputStream = new FileInputStream(file);
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "gbk");
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String text;
        while ((text = bufferedReader.readLine()) != null) {
            Matcher matcher = pattern.matcher(text);
            while (matcher.find()){
                // 只有先找到才能去取匹配到值
                System.out.println(matcher.group());
            }
        }
        System.out.println(Runtime.getRuntime().availableProcessors());
    }
}
